;;; guix-config --- additional software for a custom configuration of gnu-guix
;;; Copyright © 2020 Kolya <kolya.daemon@vfemail.net>
;;;
;;; This file is part of guix-config
;;;
;;; guix-config is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; guix-config is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (kolyad packages wm)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system meson)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (gnu packages build-tools)
  #:use-module (gnu packages freedesktop)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages man)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages web)
  #:use-module (gnu packages wm)
  #:use-module (gnu packages xdisorg)
  #:use-module (gnu packages xorg)
  #:use-module (kolyad packages)
  #:use-module (kolyad packages freedesktop))

(define-public wlroots-0.13
  (package
    (name "wlroots")
    (version "0.13.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/swaywm/wlroots")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "01plhbnsp5yg18arz0v8fr0pr9l4w4pdzwkg9px486qdvb3s1vgy"))))
    (build-system meson-build-system)
    (arguments
     `(#:configure-flags '("-Dlogind-provider=elogind")
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'hardcode-paths
           (lambda* (#:key inputs #:allow-other-keys)
             (substitute* "xwayland/server.c"
               (("Xwayland") (string-append (assoc-ref inputs
                                                       "xorg-server-xwayland")
                                            "/bin/Xwayland")))
             #t)))))
    (propagated-inputs
     `(;; As required by wlroots.pc.
       ("elogind" ,elogind)
       ("eudev" ,eudev)
       ("libinput" ,libinput)
       ("libxkbcommon" ,libxkbcommon)
       ("mesa" ,mesa)
       ("pixman" ,pixman)
       ("wayland" ,wayland-1.19)
       ("wayland-protocols" ,wayland-protocols)
       ("xcb-util-errors" ,xcb-util-errors)
       ("xcb-util-wm" ,xcb-util-wm)
       ("xorg-server-xwayland" ,xorg-server-xwayland)))
    (native-inputs
     `(("pkg-config" ,pkg-config)))
    (home-page "https://github.com/swaywm/wlroots")
    (synopsis "Pluggable, composable, unopinionated modules for building a
Wayland compositor")
    (description "wlroots is a set of pluggable, composable, unopinionated
modules for building a Wayland compositor.")
    (license license:expat)))  ; MIT license

(define-public hikari
  (package
    (name "hikari")
    (version "2.2.2")
    (source
      (origin
        (method  url-fetch)
        (uri (string-append "https://hikari.acmelabs.space/releases/"
                            "hikari-" version ".tar.gz"))
        (sha256 (base32 "1qsd1qb4bn24jh5658gxmfg6hk9p7g235gsbvnjrbfdjqsv8r6yz"))
        (patches (search-channel-patches "hikari-gnu-make.patch"))))
    (build-system gnu-build-system)
    (arguments
      `(#:tests? #f ; no check target
        #:make-flags
        (let ((out (assoc-ref %outputs "out")))
          (list (string-append "CC=" ,(cc-for-target))
                (string-append "PREFIX=" out)
                (string-append "ETC_PREFIX=" out)
                "WITH_POSIX_C_SOURCE=1"
                "WITH_XWAYLAND=1"
                "WITH_SCREENCOPY=1"
                "WITH_GAMMACONTROL=1"
                "WITH_LAYERSHELL=1"))
        #:phases
        (modify-phases %standard-phases
         (delete 'configure)            ; no configure script
         (replace 'build
          (lambda* (#:key (make-flags '()) (parallel-build? #t) #:allow-other-keys)
            (apply invoke "make" "all"
                  `(,@(if parallel-build?
                          `("-j" ,(number->string (parallel-job-count)))
                            '())
                    ,@make-flags))
            #t)))))
    (inputs
      `(("pango"    ,pango)
        ("cairo"    ,cairo)
        ("libinput" ,libinput)
        ("libucl"   ,libucl)
        ("libcap"   ,libcap)
        ("libxkbcommon" ,libxkbcommon)
        ("linux-pam" ,linux-pam)
        ("pixman"   ,pixman)
        ("wayland"  ,wayland-1.19)
        ("wlroots"  ,wlroots-0.13)
        ("elogind"  ,elogind)
        ("xorg-server-xwayland" ,xorg-server-xwayland)))
    (native-inputs `(("pkg-config" ,pkg-config)
                     ("wayland-protocols" ,wayland-protocols)))
    (home-page "https://hikari.acmelabs.space/")
    (synopsis "Lightweight stacking window compositor")
    (description "Hikari is a minimalist stacking/tiling window
compositor for wayland.")
    (license license:bsd-2)))

(define-public sway-1.6
  (package
    (name "sway")
    (version "1.6")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/swaywm/sway")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0vnplva11yafhbijrk68wy7pw0psn9jm0caaymswq1s951xsn1c8"))))
    (build-system meson-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'configure 'hardcode-paths
           (lambda* (#:key inputs #:allow-other-keys)
             ;; Hardcode path to swaybg.
             (substitute* "sway/config.c"
               (("strdup..swaybg..")
                (string-append "strdup(\"" (assoc-ref inputs "swaybg")
                               "/bin/swaybg\")")))
             ;; Hardcode path to scdoc.
             (substitute* "meson.build"
               (("scdoc.get_pkgconfig_variable..scdoc..")
                (string-append "'" (assoc-ref inputs "scdoc")
                               "/bin/scdoc'")))
             #t)))))
    (inputs `(("cairo"      ,cairo)
              ("elogind"    ,elogind)
              ("gdk-pixbuf" ,gdk-pixbuf)
              ("json-c"     ,json-c)
              ("libevdev"   ,libevdev)
              ("libinput"   ,libinput)
              ("libxkbcommon" ,libxkbcommon)
              ("pango"      ,pango)
              ("swaybg"     ,swaybg)
              ("wayland"    ,wayland-1.19)
              ("wlroots"    ,wlroots-0.13)))
    (native-inputs
     `(("linux-pam"   ,linux-pam)
       ("mesa"        ,mesa)
       ("pkg-config"  ,pkg-config)
       ("scdoc"       ,scdoc)
       ("wayland-protocols" ,wayland-protocols)))
    (home-page "https://github.com/swaywm/sway")
    (synopsis "Wayland compositor compatible with i3")
    (description "Sway is a i3-compatible Wayland compositor.")
    (license license:expat)))

;;; vim: set expandtab tabstop=2 shiftwidth=2
;;; end of file wm.scm
